package controller;

import annotation.JwtCheck;
import entity.ResultEntity;
import exception.AuthenticateException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @program: pdd
 * @description: 全局异常处理
 * @create: 2020-11-15 14:25
 **/
//@RestControllerAdvice
public class ExceptionHandlerController {
    @ExceptionHandler(AuthenticateException.class)
    public ResultEntity authenticateException(AuthenticateException e, HttpServletRequest request, HttpServletResponse response){
        return ResultEntity.failedResult(e.getResultEnum());
    }

    @JwtCheck(role = "")
    @ExceptionHandler(Exception.class)
    public ResultEntity exceptionHandler(Exception e,HttpServletRequest request, HttpServletResponse response){
        e.printStackTrace();
        return ResultEntity.failedResult();

    }
}
